package com.nobug;

import java.awt.*;
import java.awt.datatransfer.*;
import java.io.IOException;

/**
 * @author 389561407@qq.com
 * @version 1.0
 * @since 2023-02-04
 */
public class MyClipboard {


    private static Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

    public static void into(String data) {
        StringSelection stringSelection = new StringSelection(data);
        clipboard.setContents(stringSelection, null);
        try {
            String s = clipboard.getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
            System.out.println(s);
        } catch (UnsupportedFlavorException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
